import socket
from urllib.request import urlopen
import urllib.request
import re
from socketserver import TCPServer, StreamRequestHandler



def socket_client():
    s = socket.socket()

    host = socket.gethostname()
    port = 9999

    s.connect((host, port))
    s.send(b"hello world")
    s.close()


def url_open():
    localpage = urlopen(R"file:/mnt/d/project/a.txt")
    content = localpage.read()
    m = re.search(b'hello(<.*>)world', content, re.IGNORECASE)
    print(m.group(0))
    print(m.group(1))


def url_retrieve():
    urllib.request.urlretrieve(R"https://www.baidu.com/", "/mnt/d/project/a.html")


socket_client()











